package com.blog.controller;
;
import com.alibaba.fastjson.JSONObject;
import com.blog.pojo.User;
import com.blog.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


/**
 * Copyright (C), 2022
 * Author: 苏大大
 * Date: 2022-06-21 15:43
 * FileName: ReportController
 * Description:  后台数据统计模块
 */

@RequestMapping("/report")
@RestController
@Slf4j
public class ReportController extends BaseController {
    @Resource
    private ReportService reportService;


    @GetMapping("/getReport/{uid}")
    public String getReport(@PathVariable("uid") Long uid) throws Exception {
        JSONObject object=new JSONObject();
        User user=checkUser(uid);
        if(user!=null){
            object.put("data",reportService.getReport(user.getUid()));
            object.put("flag",true);
            return object.toJSONString();
        }
        object.put("flag",false);
        return object.toJSONString();
    }

    @GetMapping("/getReport2/{uid}")
    public String getReport2(@PathVariable("uid") Long uid) throws Exception {
        JSONObject object=new JSONObject();
        User user=checkUser(uid);
        if(user!=null){
            object.put("data",reportService.getReport2(user.getUid()));
            object.put("flag",true);
            return object.toJSONString();
        }
        object.put("flag",false);
        return object.toJSONString();
    }
}
